//
//  EventDetailModel.m
//  Runone
//
//  Created by runone02 on 16/10/11.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "EventDetailModel.h"
#import "RightCodeTool.h"
#import "AppConstants.h"

@implementation EventDetailModel
{
    CGFloat _constructEventHeaderH; //当前施工事件的H
    CGFloat _accidentEventHeaderH; //当前事故事件的H
    //    CGFloat _dealDetailH;          //事件描述的高度
    
    CGFloat _hisConstructEventHeaderH; //历史施工事件的H
    CGFloat _hisAccidentEventHeaderH;  //历史事故事件的H
}

+ (NSDictionary *)objectClassInArray{
    return @{
             @"EventDealList" : [EventDealListModel class],
             };
}


- (CGFloat)constructEventHeaderH {
    if (!_constructEventHeaderH) {
        
        if ([[RightCodeTool sharedTool] rightIsEqualTO:@"P04010201"]) {
            CGFloat dealDetailH ;
            CGSize maxSize   = CGSizeMake([UIScreen mainScreen].bounds.size.width - 30, MAXFLOAT);
            NSString *str = @"施工项目";
            if (_Content) {
                NSString *tempStr = [str stringByAppendingString:_Content];
                dealDetailH = [tempStr boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
                if (dealDetailH < 18) {
                    dealDetailH = 30;
                }
            }else {
                dealDetailH = 30;
            }
            _constructEventHeaderH = 200 + 200 + dealDetailH + 4*8;
//              _constructEventHeaderH = 500;
        }
    }
//    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P04010101"]) {
//        CGFloat dealDetailH ;
//        CGSize maxSize   = CGSizeMake([UIScreen mainScreen].bounds.size.width - 115, MAXFLOAT);
//        if (_Content == nil) {
//            dealDetailH = 30;
//        }else {
//            dealDetailH = [_Content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
//        }
//        _constructEventHeaderH = 200 + dealDetailH + 140 + 30 + 40;
//    }
//    
//    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P04010203"]) {
//        CGFloat dealDetailH ;
//        CGSize maxSize   = CGSizeMake([UIScreen mainScreen].bounds.size.width - 115, MAXFLOAT);
//        if (_Content == nil) {
//            dealDetailH = 30;
//        }else {
//            dealDetailH = [_Content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
//        }
//        _constructEventHeaderH = 200 + dealDetailH + 190 + 40;
//    }
//    
//    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P04010203"]&&![[RightCodeTool sharedTool] rightIsEqualTO:@"P04010101"]) {
//        CGFloat dealDetailH ;
//        CGSize maxSize   = CGSizeMake([UIScreen mainScreen].bounds.size.width - 115, MAXFLOAT);
//        if (_Content == nil) {
//            dealDetailH = 20;
//        }else {
//            dealDetailH = [_Content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
//        }
//        _constructEventHeaderH = 200 + dealDetailH + 50 + 30 + 20;
//    }
    return _constructEventHeaderH ;

}

- (CGFloat)accidentEventHeaderH {
    if (!_accidentEventHeaderH) {
        
        if ([[RightCodeTool sharedTool] rightIsEqualTO:@"P04010101"]) {
            CGFloat dealDetailH ;
            CGSize maxSize   = CGSizeMake([UIScreen mainScreen].bounds.size.width - 120, MAXFLOAT);
            if (_EventBaseInfo.IncidentDetail == nil) {
                dealDetailH = 30;
            }else {
                dealDetailH = [_EventBaseInfo.IncidentDetail boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
            }
            _accidentEventHeaderH = 200 + dealDetailH + 175;
        }
    }
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P04010101"]) {
        CGFloat dealDetailH ;
        CGSize maxSize   = CGSizeMake([UIScreen mainScreen].bounds.size.width - 120, MAXFLOAT);
        if (_EventBaseInfo.IncidentDetail == nil) {
            dealDetailH = 30;
        }else {
            dealDetailH = [_EventBaseInfo.IncidentDetail boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
        }
        _accidentEventHeaderH = 200 + dealDetailH + 145;
    }
    
    return _accidentEventHeaderH ;
}

// ******************************** -历史- ********************************
- (CGFloat)hisConstructEventHeaderH {
    if (!_hisConstructEventHeaderH) {
        CGSize maxSize   = CGSizeMake([UIScreen mainScreen].bounds.size.width - 115, MAXFLOAT);
        if (_Content == nil) {
            _constructEventHeaderH = 230 + 190;
        }else {
            CGFloat contentH = [_Content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
            _constructEventHeaderH = 210 + contentH +187 ;
        }
        
    }
    return _constructEventHeaderH ;
}

- (CGFloat)hisAccidentEventHeaderH {
    if (!_hisAccidentEventHeaderH) {
        CGSize maxSize   = CGSizeMake([UIScreen mainScreen].bounds.size.width - 30, MAXFLOAT);
        if (_Content == nil) {
            _hisAccidentEventHeaderH = 360;
        }else {
            CGFloat contentH = [_Content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]} context:nil].size.height;
            _hisAccidentEventHeaderH = 330 + contentH;
        }
        
    }
    return _hisAccidentEventHeaderH ;
}

@end
